Drizzle ORM
例
schema定義
code:ts
export const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
});
export const pets = pgTable('pets', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
ownerId: integer('owner_id').notNull().references(() => users.id),
})
pgTableはPostgreSQL向けのやつ
left join
code:ts
const result = await db.select().from(users).leftJoin(pets, eq(users.id, pets.ownerId))